<template>
  <view class="container">
    <z-paging-swiper>
      <view slot="top">
        <u-navbar height="50" title="收藏" title-size="36" title-color="#333"></u-navbar>
        <view class="tabsView">
          <u-tabs-swiper
            style="padding: 0 80rpx"
            ref="uTabs"
            font-size="32"
            :list="tabsList"
            :current="current"
            @change="tabsChange"
            :is-scroll="false"
            :show-bar="false"
            bar-width="50"
            active-color="#10A28F"
            swiper-width="750rpx"
          >
          </u-tabs-swiper>
        </view>
        <u-gap height="20" bg-color="#F0F1F2"></u-gap>
      </view>
      <swiper
        class="swiperView"
        :current="scurrent"
        @transition="transition"
        @animationfinish="animationfinish"
      >
        <swiper-item v-for="(sitem, sindex) in tabsList" class="swiperItem" :key="sindex">
          <z-paging
            ref="paging"
            v-model="itemList[sindex]"
            @query="queryList"
            :fixed="true"
            :auto="false"
            :empty-view-img="`${getImageUrl('empty.png')} `"
            empty-view-text="暂无数据~"
            :empty-view-img-style="imgStyle"
          >
            <view class="goodsItemView">
              <view
                class="itemView"
                v-if="sindex == 0"
                v-for="(item, index1) in itemList[sindex]"
                :key="index1"
              >
                <view class="top dis-flex flex-y-between">
                  <view class="title">{{ item.title }}</view>
                  <view class="price">{{ item.price }}</view>
                </view>
                <view class="yaoqiu">
                  <text class="bq">{{ item.type }}</text>
                  <text class="bq">{{ item.edu }}</text>
                  <text class="bq">{{ item.jingy }}</text>
                  <text class="bq">{{ item.count }}</text>
                </view>
                <view class="company dis-flex">
                  <view class="name">{{ item.company }}</view>
                  <view class="label">{{ item.label }}</view>
                </view>
                <view class="bottom dis-flex flex-y-center flex-y-between">
                  <view class="user dis-flex flex-y-center">
                    <u-avatar class="avatar" size="60" :src="item.user.avatar"></u-avatar>
                    <view class="label">{{ item.user.name }} · {{ item.user.zw }}</view>
                  </view>
                  <view class="add dis-flex flex-y-center">
                    <u-image
                      style="margin-bottom: 6rpx"
                      src="@/static/dw-g.png"
                      width="20rpx"
                      height="24rpx"
                    ></u-image>
                    <view class="detail">{{ item.city }}</view>
                  </view>
                </view>
              </view>
              <view
                class="itemView itemView-1"
                v-if="sindex == 1"
                v-for="(item, index1) in itemList[sindex]"
                :key="index1"
                @click="onOrderDetail(item)"
              >
                <view class="company-detail dis-flex flex-y-between flex-y-center">
                  <view class="com-l dis-flex flex-y-center">
                    <u-image
                      class="com-avarar"
                      :src="item.avatar"
                      width="90rpx"
                      height="90rpx"
                    ></u-image>
                    <view class="com-d">
                      <view class="com-t">{{ item.company }}</view>
                      <view class="com-c">
                        <text class="eq">{{ item.label }}</text>
                        <text class="eq">{{ item.guimo }}</text>
                        <text class="eq">{{ item.industry }}</text>
                      </view>
                    </view>
                  </view>
                  <u-image
                    class="more"
                    src="@/static/more.png"
                    width="16rpx"
                    height="28rpx"
                  ></u-image>
                </view>
                <view class="zw">
                  <text>{{ item.zw }}</text>
                  <text style="margin: 0 10rpx">/</text>
                  <text>{{ item.count }}</text>
                </view>
              </view>
            </view>
          </z-paging>
        </swiper-item>
      </swiper>
    </z-paging-swiper>
  </view>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      imgStyle: {
        width: '12rem'
      },
      show: false,
      current: 0,
      scurrent: 0,
      resStatus: '',
      tabsList: [
        {
          name: '职位',
          status: '',
          commentStatus: ''
        },
        {
          name: '公司',
          status: 0,
          commentStatus: ''
        }
      ],
      itemList: [
        [
          {
            title: '快递货物搬运工',
            price: '6-8K/月',
            type: '全职 ',
            edu: '高中 ',
            jingy: '经验不限 ',
            count: '招10人 ',
            company: '花果园国际物流有限公司 ',
            label: '民营企业 ',
            user: {
              zw: '人事总监',
              name: '佚名',
              avatar: ''
            },
            city: '贵阳市南明区'
          },
          {
            title: '快递货物搬运工',
            price: '6-8K/月',
            type: '全职 ',
            edu: '高中 ',
            jingy: '经验不限 ',
            count: '招10人 ',
            company: '花果园国际物流有限公司 ',
            label: '民营企业 ',
            user: {
              zw: '人事总监',
              name: '佚名',
              avatar: ''
            },
            city: '贵阳市南明区'
          }
        ],
        [
          {
            industry: '叉车运输 ',
            guimo: '10-99人 ',
            count: '招10人 ',
            company: '花果园国际物流有限公司 ',
            label: '民营企业 ',
            zw: '叉车司机等36个职位'
          },
          {
            industry: '叉车运输 ',
            guimo: '10-99人 ',
            count: '招10人 ',
            company: '花果园国际物流有限公司 ',
            label: '民营企业 ',
            zw: '叉车司机等36个职位'
          }
        ],
        [],
        []
      ],
      order_id: ''
    }
  },
  onLoad(res) {
    this.current = Number(res.index) ? Number(res.index) : 0
    this.scurrent = Number(res.index) ? Number(res.index) : 0
  },

  onShow() {
    let self = this
    this.queryList()
  },
  methods: {
    tabsChange(index) {
      this.scurrent = index
    },
    transition(e) {
      let dx = e.detail.dx
      this.$refs.uTabs.setDx(dx)
    },
    animationfinish(e) {
      this.current = e.detail.current
      this.scurrent = e.detail.current
      this.$refs.uTabs.setFinishCurrent(e.detail.current)
      if (this.itemList[this.current].length == 0) {
        this.queryList()
      }
    },
    queryList(pageNo = 1, pageSize = 10) {
      this.$u
        .get('/app-api/trade/order/page', {
          pageNo,
          pageSize,
          status: this.tabsList[this.scurrent].status,
          commentStatus: this.tabsList[this.scurrent].commentStatus
        })
        .then((res) => {
          let dynamicPaging = this.scurrent > 0 ? 'paging' + this.scurrent : 'paging'
          this.$refs.paging[this.scurrent].complete(res.data.list)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
page {
  height: 100%;
  background: #f0f1f2;
}
.goodsItemView {
  padding: 0 20rpx;
}
.itemView {
  height: 300rpx;
  background: #ffffff;
  border-radius: 10rpx;
  padding: 10rpx 20rpx;
  margin-bottom: 20rpx;
  display: flex;
  flex-flow: column;
  justify-content: space-around;
  .top {
    // margin-bottom: 22rpx;
    .title {
      font-weight: 600;
      font-size: 34rpx;
      color: #333333;
    }
    .price {
      font-weight: 600;
      font-size: 34rpx;
      color: #fa453c;
    }
  }
  .yaoqiu {
    // margin-bottom: 22rpx;
    .bq {
      background: #f0f0f0;
      border-radius: 5rpx;
      padding: 8rpx;
      font-size: 20rpx;
      color: #666666;
      margin-right: 10rpx;
    }
  }
  .company {
    font-size: 28rpx;
    color: #333333;
    // margin-bottom: 22rpx;
    .name {
      margin-right: 40rpx;
    }
  }
  .bottom {
    .user {
      .label {
        margin-left: 10rpx;
        font-size: 28rpx;
      }
    }
    .add {
      font-size: 26rpx;
      color: #999999;
      .detail {
        margin-left: 10rpx;
      }
    }
  }
}
.itemView-1 {
  height: 180rpx;
  .company-detail {
    .com-avarar {
      margin-right: 20rpx;
      border-radius: 10rpx;
    }
    .com-d {
      height: 90rpx;
      display: flex;
      flex-flow: column;
      justify-content: space-between;
      padding: 4rpx 0;
      .com-t {
        font-size: 30rpx;
        font-weight: 600;
      }
      .com-c {
        color: #999999;
        font-size: 24rpx;
        .eq {
          border-right: 1rpx solid #999999;
          padding-right: 10rpx;
          margin-right: 14rpx;
        }
        .eq:last-child {
          border: none;
        }
      }
    }
  }
  .zw {
    margin-left: 110rpx;
    color: #666666;
    font-size: 26rpx;
  }
}
</style>
